<?php
echo "vao day";
//exit();
    require_once '../../model/global.inc.php'; 
     if(isset($_SESSION['logged_in']))
    {
        $user = unserialize($_SESSION['user']);
        $memid = $user->memid;
    }
    $oldPass = $_GET['oldpass'];  
    $newPass = $_GET['pass'];
echo $newPass;
//exit();	
    $newPass_confirm = $_GET['conf'];
    $success = true;  
    $userTools = new UserTools();  
    if($newPass != $newPass_confirm)
    {
		echo "vao 3";
        $success = FALSE;
    }
	echo $userTools->checkPassExists($oldPass,$memid);
    if($userTools->checkPassExists($oldPass,$memid)==FALSE)
    {
		echo "vao 1";
        $success = FALSE;
    }
    if($newPass == '' || $newPass_confirm== '' || $oldPass == '')
    {
		echo "vao 2";
        $success = FALSE;
    }
    if($success==true)
    {
        $data['password'] = md5($newPass);
        $data['memid'] = $memid;
        $newUser = new User($data);
		print_r($newUser);
        $newUser->changePass();
        $userTools->logout();
        echo "Change Pass success";
        //echo "<script>window.location='index.php';</script>";
    }

?>
